var app = getApp();

Page({
	data: {
		phoneNumber: '',
		proposal: ''
	},
	onShareAppMessage: function () {
    	return {
      		title: '重庆大学体育学院研究生支部委员会',
      		path: 'cqdx_communist/pages/index/index'
   		}
  	},




	bindPhoneInput(e) {
		this.setData({phoneNumber: e.detail.value})
	},
	inputProposalInput(e) {
		this.setData({proposal: e.detail.value})
	},
	handleSubmit() {
		let phoneReg = /^[1][3,4,5,7,8][0-9]{9}$/;
		if (!phoneReg.test(this.data.phoneNumber)) {
			wx.showToast({
				title: '请输入正确的手机号码',
				icon: 'none',
				duration: 2000
			})
			return;
		}
		if (!this.data.proposal) {
			wx.showToast({
				title: '请填写您的建议后提交',
				icon: 'none',
				duration: 2000
			})
			return;
		}

		app.util.request({
			url: 'entry/wxapp/Suggestion',
			data: {
				openid: app.globalData.userInfo.openId,
				telephone: this.data.phoneNumber,
				detail: this.data.proposal
			},
			success:(res) => {
				wx.showToast({
					title: '反馈成功,感谢您的宝贵意见！',
					icon: 'none',
					duration: 2000
				})
				this.setData({phoneNumber: ''})
				this.setData({proposal: ''})
			}
		})
	}
})